package cn.pn.project.service;

import cn.pn.project.mapper.base.ImgMapper;
import cn.pn.project.pojo.base.Img;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/img")
public class ImgService {
    @Autowired
    private ImgMapper imgMapper;

    /**
     * 添加图片
     * @param img
     * @return
     * @throws Exception
     */
    @RequestMapping("/addImg")
    public Integer addImg(@RequestBody Img img) throws Exception {
        return imgMapper.addImg(img);
    }

    /**
     * 修改图片关联id
     * @param releId 关联id
     * @param imgId 图片id
     * @return
     * @throws Exception
     */
    @RequestMapping("/updateReleId")
    public Integer updateReleId(@RequestParam("releId") Integer releId, @RequestParam("imgId") Integer imgId) throws Exception {
        return imgMapper.updateReleId(releId,imgId);
    }

    /**
     * 查询最大主键
     * @return
     * @throws Exception
     */
    @RequestMapping("/max")
    Integer getMaxId() throws Exception{
        return imgMapper.getMaxId();
    }

}
